package edu.java.lectures.lec15.collections.usage;

import java.util.SortedMap;
import java.util.TreeMap;

import edu.java.homework.hw09.exercises.person.Gender;
import edu.java.homework.hw09.exercises.person.Person;

public class SortedMapTest {

    public static void main(String[] args) {
	Person persona1 = new Person("Petyr", "Vasilev", "Petrov", 40,
		Gender.MALE, "Sofiq", 2);
	Person persona2 = new Person("Dimitrichka", "Pencheva", "Nikolova", 32,
		Gender.FEMALE, "Karnobat", 1);
	Person persona3 = new Person("Pencho", "Minchev", "Asenov", 65,
		Gender.MALE, "Blagoevgrad", 3);
	Person persona4 = new Person("Violeta", "Georgieva", "Deneva", 15,
		Gender.FEMALE, "Asenovgrad", 0);
	Person persona5 = new Person("Stoencho", "Borisov", "Dimitrov", 23,
		Gender.MALE, "Montana", 0);

	// the keys are sorted by their natural order
	SortedMap<Person, String> person2firstNameMap = new TreeMap<Person, String>();

	person2firstNameMap.put(persona1, persona1.getFisrtName());
	person2firstNameMap.put(persona2, persona2.getFisrtName());
	person2firstNameMap.put(persona3, persona3.getFisrtName());
	person2firstNameMap.put(persona4, persona4.getFisrtName());
	person2firstNameMap.put(persona5, persona5.getFisrtName());

	System.out.println(person2firstNameMap);

	// Thing class need to implement Comparable interface
	SortedMap<Thing, String> thingSortedMap = new TreeMap<Thing, String>();
	thingSortedMap.put(new Thing("a"), "a");
	thingSortedMap.put(new Thing("c"), "c");
	thingSortedMap.put(new Thing("b"), "b");
	System.out.println(thingSortedMap);
    }
}
